import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 菜谱分类信息 */
export interface RecipesType {
  id: number // 主键ID
  typeId: string // 菜谱分类ID
  typeName: string // 分类名称
  sort?: number // 排序
  status?: number // 状态
}

// 菜谱分类 API
export const RecipesTypeApi = {
  // 查询菜谱分类分页
  getRecipesTypePage: async (params: any) => {
    return await request.get({ url: `/school/recipes-type/page`, params })
  },
  getRecipesType: async (id: number) => {
    return await request.get({ url: `/school/recipes-type/get?id=` + id })
  },
  // 获得菜谱分类精简列表
  getRecipesTypeSimpleList: async () => {
    return await request.get({ url: `/school/recipes-type/simple-list` })
  },
  // 获得菜谱分类及分类下菜谱全部数据
  getRecipeFoodTree: async () => {
    return await request.get({ url: `/school/recipes-type/tree` })
  },
  // 新增菜谱分类
  createRecipesType: async (data: RecipesType) => {
    return await request.post({ url: `/school/recipes-type/create`, data })
  },

  // 修改菜谱分类
  updateRecipesType: async (data: RecipesType) => {
    return await request.put({ url: `/school/recipes-type/update`, data })
  },

  // 删除菜谱分类
  deleteRecipesType: async (id: number) => {
    return await request.delete({ url: `/school/recipes-type/delete?id=` + id })
  },

  /** 批量删除菜谱分类 */
  deleteRecipesTypeList: async (ids: number[]) => {
    return await request.delete({ url: `/school/recipes-type/delete-list?ids=${ids.join(',')}` })
  },

  // 导出菜谱分类 Excel
  exportRecipesType: async (params) => {
    return await request.download({ url: `/school/recipes-type/export-excel`, params })
  }
}
